package week5;

public class Sorting1 {
    public static <T extends Comparable<T>>
    void bubbleSort(T[] data)
    {
        int scan,position;
        int count=0;
        T temp;
        long starTime=System.currentTimeMillis();

        for (position =5; position>0; position--)
        {
             for (scan = 0; scan<data.length-position; scan++)
            {
                count++;
                if (data[scan].compareTo(data[scan+position]) > 0)
                    swap(data, scan, scan + position);
            }
        }
        long endTime=System.currentTimeMillis();
        long Time=endTime-starTime;
        System.out.println(count+" "+Time);

    }
    private static <T extends Comparable<T>>
    void swap(T[] data, int index1, int index2)
    {
        T temp = data[index1];
        data[index1] = data[index2];
        data[index2] = temp;
    }
}
